package GUI;

import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;

import start.DBhandler;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class LoginUser extends JFrame {
	private JTextField textField;
	private JTextField textField_1;
	public int flag=-1;
	public DBhandler log;
	
	public LoginUser() {
		getContentPane().setFont(new Font("Trebuchet MS", Font.PLAIN, 18));
		getContentPane().setLayout(null);
		
		JLabel lblLoginSystem = new JLabel("LOGIN SYSTEM");
		lblLoginSystem.setFont(new Font("Tahoma", Font.PLAIN, 18));
		lblLoginSystem.setForeground(Color.BLUE);
		lblLoginSystem.setBounds(130, 0, 141, 14);
		getContentPane().add(lblLoginSystem);
		
		textField = new JTextField();
		textField.setBounds(126, 37, 86, 20);
		getContentPane().add(textField);
		textField.setColumns(10);
		
		JLabel lblUserid = new JLabel("USER_ID");
		lblUserid.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblUserid.setBounds(25, 40, 78, 14);
		getContentPane().add(lblUserid);
		
		JLabel lblPassword = new JLabel("PASSWORD");
		lblPassword.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblPassword.setBounds(25, 85, 86, 14);
		getContentPane().add(lblPassword);
		
		textField_1 = new JTextField();
		textField_1.setBounds(126, 84, 86, 20);
		getContentPane().add(textField_1);
		textField_1.setColumns(10);
		
		JButton btnOk = new JButton("OK");
		btnOk.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(e.getSource()=="cancel")
					flag=0;
				else
				{
					flag=1;
					try {
						log=new DBhandler();
					} catch (Exception e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
					log.login_method(textField.getText(),textField_1.getText());
				}
			}
		});
		btnOk.setBounds(89, 172, 89, 23);
		getContentPane().add(btnOk);
		
		JButton btnCancel = new JButton("CANCEL");
		btnCancel.setBounds(231, 172, 89, 23);
		getContentPane().add(btnCancel);
	}
}
